Cleanest way to loop over an array of objects and replace a property